package com.example.tests;


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;


public class GroupCreationTests2 extends TestBase 	{

	Random rnd = new Random();
	
	@DataProvider(name = "randomGroups")
	public Iterator<Object[]> generateRandomGroups() {
		List<Object[]> list = new ArrayList<Object[]>();
		for (int i = 0; i < 5; i++) {
			GroupObject group = new GroupObject()
				.setName("")
				.setHeader("")
				.setFooter("");
			list.add(new Object[]{group});
		}
		return list.iterator();
	}


	@Test
	public void testGroupWithEmptyDataCanBeCreated() throws Exception {
		GroupObject emptyDataGroup = new GroupObject()
		.setName("").setHeader("").setFooter("");
		Set<GroupObject> oldList = app.getGroupHelper().getGroups();
		app.getGroupHelper().createGroup(emptyDataGroup);
		Set<GroupObject> newList = app.getGroupHelper().getGroups();
		verifyGroupAdded (oldList, emptyDataGroup, newList);
		//validate
		// ERROR: Caught exception [ERROR: Unsupported command [isTextPresent]]
	}

	@Test(dataProvider = "randomGroups")
	public void testValidGroupCanBeCreated(GroupObject emptyDataGroup) throws Exception {
		
		Set<GroupObject> oldList = app.getGroupHelper().getGroups();
		//action
		app.getGroupHelper().createGroup(emptyDataGroup);
		//verification
		Set<GroupObject> newList = app.getGroupHelper().getGroups();
//		assertThat(newList, equalTo(oldList.withAdded(validGroup)));
		verifyGroupAdded (oldList, emptyDataGroup, newList);
		//validate
		
	}

}
